import axios from './axios';
// 获取角色列表
export async function getRoleList() {
  let res = await axios.get("/rolelist");
  return res.list
}

// 获取树形控件的数据
export async function getTreeDataFn() {
  let res = await axios.get("/menulist?istree=1");
  return res.list
}

// 新增角色
export async function roleAddFn(data) {
  let res = await axios.post("/roleadd", data);
  return res.msg
}

// 修改角色
export async function roleEditFn(data) {
  let res = await axios.post("/roleedit", data);
  return res.msg
}

// 获取管理列表
export async function getAdminListFn(data) {
  
  let res = await axios.get("/userlist",{ params: data});
  return res.list
}

// 获取管理员总数
export async function getAdminNumFn() {
  let res = await axios.get("/usercount");
  return res.list[0].total
}
// 新增分类
export async function cateAddFn(data) {
  let res = await axios.post("/cateadd", data);
  return res.msg
}

// 修改分类
export async function cateEditFn(data) {
  let res = await axios.post("/cateedit", data);
  return res.msg
}

// 获取商品分类列表
export async function getCateListFn() {
  let res = await axios.get("/catelist", {params: {istree: 1}});
  return res.list
}

// 根据一级分类获取二级分类列表
export async function getSecondCateListFn(pid) {
  let res = await axios.get("/catelist", {params: {pid: pid}});
  return res.list
}

// 获取商品规格列表
export async function getGoodsSpecsFn() {
  let res = await axios.get("/specslist");
  return res.list
}

// 获取商品列表（分页）
export async function getGoodsListFn() {
  let res = await axios.get("/goodslist", {params: {page: 1, size: 15}});
  return res.list
}

// 修改商品
export async function goodsEditFn(data) {
  let res = await axios.post("/roleedit", data);
  return res.msg
}